﻿namespace Collaboris.Saf.Actions.Wss.Entities
{
    using System;
    using System.Xml.Serialization;

    using SharePoint.Wss.Attributes;
    using SharePoint.Wss.Entities;

    using Utils;

    using System.Data;

    [CollaborisClass(
        Title = "Import Data Set To List Info",
        ReleaseStatus = ReleaseStatus.Development,
        DisableDocumentation = false,
        ContactAuthorEmail = "Support@Collaboris.co.uk",
        Summary = "Defines the parameters to import the DataSet data into the list."
    )]
    [Serializable]
    public class ImportDataSetToListInfo : WSSEntityBase
    {
        private string listName;
        private SerializableStringDictionary rowDefinition;
        private DataSet data;

        [CollaborisProperty(
           Summary = "Specifies the name of the list to update.",
           Title = "ListName",
           Example = @"TestTasks",
           Required = true,
           InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public string ListName
        {
            get
            {
                return listName;
            }
            set
            {
                listName = value;
            }
        }

        [CollaborisProperty(
            Summary = "Maps the list column name " +
                     "and the DataSet column name",
            Title = "RowDefinition",
            Example = @"<dictionary>							
                            <entry key=""Title"" value=""Title"" />
							<entry key=""Description"" value=""Description"" />							                
						 </dictionary>",
            SerializedExample = @"<Dictionary type=""Collaboris.Utils.SerializableObjectDictionary`1[[System.String]]"">
                                    <item type=""System.String"">
                                        <key>
                                          <string>Title</string>
                                        </key>
                                        <value>
                                          <string>Title</string>
                                        </value>
                                    </item>
                                    <item type=""System.String"">
                                        <key>
                                          <string>Description</string>
                                        </key>
                                        <value>
                                          <string>Description</string>
                                        </value>
                                    </item>
                                </Dictionary>",
            Remarks = "",
            InputHint = InputHint.ObjectCollection,
            Required = true)]
        [XmlElement]
        public SerializableStringDictionary RowDefinition
        {
            get
            {
                return rowDefinition;
            }
            set
            {
                rowDefinition = value;
            }
        }

        [CollaborisProperty(
           Summary = "Specifies a dataset containing the data to insert / update into the list.",
           Title = "List Data Set",
           Example = @"",
           RenderAsExpression = true,
           SerializedExample = @"$(DataSetPassedInFromMSBuild)",
           Remarks = @"This needs to be passed in from another action that can supply the data." +
                     @" Please look at <a href=""Collaboris.Saf.Actions.DataSet.GetDataSetFromCSV.html"">Get DataSet From CSV</a>" +
                     @" for an example on how to get a data set from a CSV file.",
           Required = true,
           InputHint = InputHint.DataSet)]
        [XmlElement]
        public DataSet Data
        {
            get
            {
                return data;
            }
            set
            {
                data = value;
            }
        }
    }
}
